package com.youdoneed.news.news.web;

import com.youdoneed.news.common.vo.ResultMessage;
import com.youdoneed.news.news.service.CmfOptionsService;
import com.youdoneed.news.news.vo.CmfPostsListOfFriends;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

@RestController
@RequestMapping(value = "/option", method = {RequestMethod.GET, RequestMethod.POST})
@Api(value = "新闻配置控制器", description = "新闻配置控制器")
public class CmfOptionsController {
    private static final Logger logger = LoggerFactory.getLogger(CmfOptionsController.class);

    @Autowired
    private CmfOptionsService cmfOptionsService;

    /**
     * 获取好友浏览过的新闻列表
     *
     * @throws ParseException
     * @throws NumberFormatException
     * @author hexz
     * @date 2017.7.3
     */
    @RequestMapping(value = "/getPostsKeyWords", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(notes = "获取搜索热词", value = "获取搜索热词")
    public ResultMessage<List<CmfPostsListOfFriends>> getPostsKeyWords(
    ) throws NumberFormatException, ParseException {
        String optionName = "news_keyword";
        return ResultMessage.newSuccess("获取搜索热词").setData(
                cmfOptionsService.getOptionsByName(optionName));
    }
}
